package bookmanagement;

import bookmanagement.book.BookList;
import bookmanagement.user.AdminUser;
import bookmanagement.user.NormalUser;
import bookmanagement.user.User;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = login();
        while (true) {
            int choice = user.menu();
            if (choice == -1) {
                System.out.println("Bye~~");
                System.exit(0);
            }
            user.doOperation(choice,bookList);
        }
    }

    public static User login() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的姓名");
        String name = scanner.nextLine();
        System.out.println("请输入您的身份，1表示普通用户，0表示管理员");
        int who = scanner.nextInt();
        if (who == 1) {
            return new NormalUser(name);
        }else {
            return new AdminUser(name);
        }
    }
}
